/**
 * Copyright (C) 2011, mordredd666 [_at_] gmail.com
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 3 of the License, or
 * (at your option) any later version.
 *  
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 *  
 * You should have received a copy of the GNU General Public License
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
 */
package de.mordred.gui;

import java.awt.GridLayout;
import java.awt.Image;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.ImageIcon;
import javax.swing.JButton;

import de.mordred.Loader;
import de.mordred.Main;
import de.mordred.gui.einstellungen.Einstellungen;
import de.mordred.gui.lernen.FachSelection;
import de.mordred.gui.pruefung.JahrSelection;

public class SelectionScreen extends FixedPanel
{

	// Lernen, Prüfung
	// Kommentare , Nachschlagen
	// Statistik, Einstellungen

	private static final long serialVersionUID = 5391502856531269825L;

	public SelectionScreen()
	{
		this.setLayout(new GridLayout(3, 2));

		ImageIcon lernenicon = Loader.getImageIcon("Lernen.png");
		scale(lernenicon);
		JButton lernen = new JMyButton("Lernen", lernenicon);

		ImageIcon prüficon = Loader.getImageIcon("Pruefung.png");
		scale(prüficon);
		JButton prüfung = new JMyButton("Prüfung", prüficon);

		ImageIcon kommicon = Loader.getImageIcon("Kommentare.png");
		scale(kommicon);
		JButton kommentare = new JMyButton("Kommentare", kommicon);

		ImageIcon nachicon = Loader.getImageIcon("Nachschlagen.png");
		scale(nachicon);
		JButton nachschlagen = new JMyButton("Nachschlagen", nachicon);

		ImageIcon staticon = Loader.getImageIcon("Statistik.png");
		scale(staticon);
		JButton statistik = new JMyButton("Statistik", staticon);

		ImageIcon setticon = Loader.getImageIcon("Einstellungen.png");
		scale(setticon);
		JButton einstellungen = new JMyButton("Einstellungen", setticon);

		this.add(lernen);

		lernen.addActionListener(new ActionListener()
		{
			@Override
			public void actionPerformed(ActionEvent e)
			{
				Main.setNextPanel(new FachSelection(Main.getFächer()));
			}
		});

		prüfung.addActionListener(new ActionListener()
		{

			@Override
			public void actionPerformed(ActionEvent e)
			{
				Main.setNextPanel(new JahrSelection());
			}
		});

		einstellungen.addActionListener(new ActionListener()
		{

			@Override
			public void actionPerformed(ActionEvent e)
			{
				Main.setNextPanel(Einstellungen.getInstance());
			}
		});

		this.add(prüfung);
		this.add(kommentare);
		this.add(nachschlagen);
		this.add(statistik);
		this.add(einstellungen);
	}

	private void scale(ImageIcon ico)
	{
		ico.setImage(ico.getImage().getScaledInstance(120, 93, Image.SCALE_FAST));
	}

	@Override
	public String getTitel()
	{
		return "Hauptmenü";
	}
}
